namespace OpenVision.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Init : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Changes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        HasUserRangeChanged = c.Boolean(nullable: false),
                        HasUserPositionChanged = c.Boolean(nullable: false),
                        HasSoundMessageChanged = c.Boolean(nullable: false),
                        HasCollarPositionChanged = c.Boolean(nullable: false),
                        HasTheCallButtonPressed = c.Boolean(nullable: false),
                        Leash_Id = c.Int(),
                        User_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Collars", t => t.Leash_Id)
                .ForeignKey("dbo.Users", t => t.User_Id)
                .Index(t => t.Leash_Id)
                .Index(t => t.User_Id);
            
            CreateTable(
                "dbo.Collars",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Latitude = c.Double(nullable: false),
                        Longitude = c.Double(nullable: false),
                        User_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Users", t => t.User_Id)
                .Index(t => t.User_Id);
            
            CreateTable(
                "dbo.Users",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Nickname = c.String(nullable: false, maxLength: 50),
                        Password = c.String(nullable: false, maxLength: 40, fixedLength: true),
                        Email = c.String(nullable: false, maxLength: 75),
                        SessionKey = c.String(),
                        Latitude = c.Double(nullable: false),
                        Longitude = c.Double(nullable: false),
                        Range = c.Int(nullable: false),
                        SoundMessage = c.Binary(),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Changes", "User_Id", "dbo.Users");
            DropForeignKey("dbo.Changes", "Leash_Id", "dbo.Collars");
            DropForeignKey("dbo.Collars", "User_Id", "dbo.Users");
            DropIndex("dbo.Changes", new[] { "User_Id" });
            DropIndex("dbo.Changes", new[] { "Leash_Id" });
            DropIndex("dbo.Collars", new[] { "User_Id" });
            DropTable("dbo.Users");
            DropTable("dbo.Collars");
            DropTable("dbo.Changes");
        }
    }
}
